#!/usr/bin/env python
#
# GAE-Appengine-CMS
# Copyright (c) 2010 ITBelt (itbelt.com)
# Licensed under the GPL license:
# http://www.gnu.org/licenses/gpl.html
#

import datetime
import time

from google.appengine.ext.webapp import template


def rfc3339date(date):
  if not date: return ''
  date = date + datetime.timedelta(seconds=-time.timezone)
  if time.daylight:
    date += datetime.timedelta(seconds=time.altzone)
  return date.strftime('%Y-%m-%dT%H:%M:%SZ')

def xhtml(text):
  if not text: return ''
  return text.replace('<br>','<br />')

register = template.create_template_register()
register.filter(rfc3339date)
register.filter(xhtml)